{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 51,
   "metadata": {},
   "outputs": [],
   "source": [
    "from preprocess import *\n",
    "import keras\n",
    "from keras.models import Sequential\n",
    "from keras.layers import Dense, Dropout, Flatten, Conv2D, MaxPooling2D, LSTM\n",
    "from keras.utils import to_categorical\n",
    "import wandb\n",
    "from wandb.keras import WandbCallback\n",
    "import matplotlib.pyplot as plt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Saving vectors of label - 'bed':   0%|          | 0/1713 [00:00<?, ?it/s]"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W&B Run: https://app.wandb.ai/l2k2/ml-class-videos_cnn-audio/runs/n5fqsruy\n",
      "Call `%%wandb` in the cell containing your training loop to display live results.\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Saving vectors of label - 'bed': 100%|██████████| 1713/1713 [00:12<00:00, 140.67it/s]\n",
      "Saving vectors of label - 'happy': 100%|██████████| 1742/1742 [00:13<00:00, 125.22it/s]\n",
      "Saving vectors of label - 'cat': 100%|██████████| 1733/1733 [00:13<00:00, 131.24it/s]\n"
     ]
    }
   ],
   "source": [
    "wandb.init()\n",
    "config = wandb.config\n",
    "\n",
    "config.max_len = 11\n",
    "config.buckets = 20\n",
    "\n",
    "# Save data to array file first\n",
    "save_data_to_array(max_len=config.max_len, n_mfcc=config.buckets)\n",
    "\n",
    "labels=[\"bed\", \"happy\", \"cat\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "# # Loading train set and test set\n",
    "X_train, X_test, y_train, y_test = get_train_test()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [],
   "source": [
    "# # Feature dimension\n",
    "channels = 1\n",
    "config.epochs = 50\n",
    "config.batch_size = 100\n",
    "\n",
    "num_classes = 3\n",
    "\n",
    "X_train = X_train.reshape(X_train.shape[0], config.buckets, config.max_len, channels)\n",
    "X_test = X_test.reshape(X_test.shape[0], config.buckets, config.max_len, channels)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 37,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0.0\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAKYAAAD8CAYAAAD9nd/mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAEL1JREFUeJzt3XuMXOV9xvHvs7O73mAv2AbfcYA2FpKLglsh0yhUgpJQgwCnVdrailqnpXKKitRIrSraShCl/6Sq0kgtKChNLJwqAdq0TqxiLhZtRaiAsCATri6Oa4rXYAM2vq/39usfe4ym61nve/aM2Xdnno9k7cyZ35zzDvswt3ff31FEYJabjukegFkjDqZlycG0LDmYliUH07LkYFqWHEzLkoNpWXIwLUud0z2ARnrm9sScJXOSaud2nkjeb6dGkmsPj5yXXHvwaNpYy9Bwem334fTHpYHB5NoYHU0fRKIBjjMYpzRZXZbBnLNkDrdsviWp9pYLdyTvd3HtcHLtvx1ZlVz7wH9+Ork2amlTwD37a8n7/Pgj6Y9Lr/1Pcu3oyZPJtSRObT8bTyTVVXopl7RG0k5JuyTd2eD2WZIeKm5/VtKlVY5n7WPKwZRUA+4FbgRWAuslrRxXdhtwKCI+AXwD+OupHs/aS5VnzNXArojYHRGDwIPA2nE1a4HNxeUfANdLmvT9hVmVYC4D3qq7vrfY1rAmIoaBw8CFFY5pbSKbr4skbZTUJ6lv4IOB6R6OTbMqwewHltddv7jY1rBGUidwAfB+o51FxLci4qqIuKpnbk+FYVkrqBLM54AVki6T1A2sA7aOq9kKbCgufx749/CfzFuCKX+PG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sBq6sOD5rU575sSw5mJYlB9Oy5GBalhxMy5KDaVnKcorlZHTx6qm0M6/sG06fDlzamb5CsEwz1tRpRoDFnWf7Q6y6fSp9n2WmLw+MpK+oLNO4dSiaGyU/Y1qWHEzLkoNpWXIwLUsOpmXJwbQsOZiWJQfTsuRgWpYcTMuSItLPWfhRkfQu8Oa4zRcBrdg4oVUfFzR+bJdExILJ7phlMBuR1NeKLWZa9XFBtcfml3LLkoNpWZpJwfzWdA/gHGnVxwUVHtuMeY9p7WUmPWNaG5kRwZS0RtJOSbsk3Tnd42kWSXskvSRph6S+6R5PFZI2STog6eW6bfMlbZf0RvEzeblB9sGUVAPuBW4EVgLrJa2c3lE11XURsaoFvjK6H1gzbtudwBMRsQJ4orieJPtgMtYhbldE7I6IQeBBYO00j8nGKdpLHhy3eS2wubi8Gfhc6v5mQjCXAW/VXd9bbGsFrd7YdlFEvF1cfoexRmtJslwl2UaSG9vOdBERkpK/ApoJz5j9wPK66xcX22a8Mo1tZ6j9kpYAFD8PpN5xJgTzOWCFpMskdTPWl3PrNI+psjZpbLsV2FBc3gD8KPWO2b+UR8SwpDuAx4AasCkiXpnmYTXDImDL2Ik/6AS+P5Mb2xYNfq8FLpK0F7gb+BrwT0Wz3zcZO8NJ2v4882M5mgkv5daGHEzLkoNpWXIwLUsOpmXJwbQsOZiWJQfTsvR/3pYLy+rQxs0AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "plt.imshow(X_train[100, :, :, 0])\n",
    "print(y_train[100])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "y_train_hot = to_categorical(y_train)\n",
    "y_test_hot = to_categorical(y_test)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "\n",
    "X_train = X_train.reshape(X_train.shape[0], config.buckets, config.max_len)\n",
    "X_test = X_test.reshape(X_test.shape[0], config.buckets, config.max_len)\n",
    "\n",
    "model = Sequential()\n",
    "model.add(Flatten(input_shape=(config.buckets, config.max_len)))\n",
    "model.add(Dense(num_classes, activation='softmax'))\n",
    "model.compile(loss=\"categorical_crossentropy\",\n",
    "                  optimizer=\"adam\",\n",
    "                  metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W&B Run: https://app.wandb.ai/l2k2/ml-class-videos_cnn-audio/runs/uaom4fuw\n",
      "Call `%%wandb` in the cell containing your training loop to display live results.\n",
      "Train on 3112 samples, validate on 2076 samples\n",
      "Epoch 1/50\n",
      "3112/3112 [==============================] - 1s 252us/step - loss: 9.6424 - acc: 0.3817 - val_loss: 8.9929 - val_acc: 0.4253\n",
      "Epoch 2/50\n",
      "3112/3112 [==============================] - 0s 149us/step - loss: 8.8110 - acc: 0.4341 - val_loss: 8.2306 - val_acc: 0.4653\n",
      "Epoch 3/50\n",
      "3112/3112 [==============================] - 0s 152us/step - loss: 7.8625 - acc: 0.4820 - val_loss: 6.7555 - val_acc: 0.5313\n",
      "Epoch 4/50\n",
      "3112/3112 [==============================] - 0s 150us/step - loss: 5.1861 - acc: 0.6144 - val_loss: 4.2210 - val_acc: 0.6696\n",
      "Epoch 5/50\n",
      "3112/3112 [==============================] - 0s 144us/step - loss: 3.5821 - acc: 0.7208 - val_loss: 3.6203 - val_acc: 0.7163\n",
      "Epoch 6/50\n",
      "3112/3112 [==============================] - 1s 213us/step - loss: 2.9745 - acc: 0.7561 - val_loss: 3.2614 - val_acc: 0.7447\n",
      "Epoch 7/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 2.7470 - acc: 0.7789 - val_loss: 3.3918 - val_acc: 0.7331\n",
      "Epoch 8/50\n",
      "3112/3112 [==============================] - 0s 143us/step - loss: 2.5837 - acc: 0.7895 - val_loss: 2.9279 - val_acc: 0.7693\n",
      "Epoch 9/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 2.2898 - acc: 0.8040 - val_loss: 2.8437 - val_acc: 0.7799\n",
      "Epoch 10/50\n",
      "3112/3112 [==============================] - 0s 145us/step - loss: 2.2676 - acc: 0.8107 - val_loss: 2.8002 - val_acc: 0.7722\n",
      "Epoch 11/50\n",
      "3112/3112 [==============================] - 0s 139us/step - loss: 2.1765 - acc: 0.8217 - val_loss: 2.7590 - val_acc: 0.7876\n",
      "Epoch 12/50\n",
      "3112/3112 [==============================] - 0s 139us/step - loss: 2.0598 - acc: 0.8258 - val_loss: 2.7624 - val_acc: 0.7837\n",
      "Epoch 13/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 2.0148 - acc: 0.8268 - val_loss: 2.7273 - val_acc: 0.7808\n",
      "Epoch 14/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 1.9404 - acc: 0.8393 - val_loss: 2.8900 - val_acc: 0.7659\n",
      "Epoch 15/50\n",
      "3112/3112 [==============================] - 0s 152us/step - loss: 1.9122 - acc: 0.8287 - val_loss: 2.7173 - val_acc: 0.7832\n",
      "Epoch 16/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 1.8676 - acc: 0.8445 - val_loss: 2.7524 - val_acc: 0.7775\n",
      "Epoch 17/50\n",
      "3112/3112 [==============================] - 0s 143us/step - loss: 2.0001 - acc: 0.8242 - val_loss: 2.6138 - val_acc: 0.7982\n",
      "Epoch 18/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 1.7973 - acc: 0.8480 - val_loss: 2.6646 - val_acc: 0.7823\n",
      "Epoch 19/50\n",
      "3112/3112 [==============================] - 0s 144us/step - loss: 1.7860 - acc: 0.8461 - val_loss: 2.6840 - val_acc: 0.7828\n",
      "Epoch 20/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 1.7758 - acc: 0.8442 - val_loss: 2.6632 - val_acc: 0.7784\n",
      "Epoch 21/50\n",
      "3112/3112 [==============================] - 0s 143us/step - loss: 1.6855 - acc: 0.8570 - val_loss: 2.6435 - val_acc: 0.7847\n",
      "Epoch 22/50\n",
      "3112/3112 [==============================] - 0s 139us/step - loss: 1.6973 - acc: 0.8464 - val_loss: 2.6579 - val_acc: 0.7842\n",
      "Epoch 23/50\n",
      "3112/3112 [==============================] - 0s 145us/step - loss: 1.7248 - acc: 0.8403 - val_loss: 2.6522 - val_acc: 0.7832\n",
      "Epoch 24/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 1.6680 - acc: 0.8551 - val_loss: 2.9123 - val_acc: 0.7664\n",
      "Epoch 25/50\n",
      "3112/3112 [==============================] - 0s 134us/step - loss: 1.6825 - acc: 0.8544 - val_loss: 2.7090 - val_acc: 0.7856\n",
      "Epoch 26/50\n",
      "3112/3112 [==============================] - 0s 152us/step - loss: 1.7272 - acc: 0.8445 - val_loss: 2.6379 - val_acc: 0.7861\n",
      "Epoch 27/50\n",
      "3112/3112 [==============================] - 0s 140us/step - loss: 1.6018 - acc: 0.8599 - val_loss: 2.6723 - val_acc: 0.7861\n",
      "Epoch 28/50\n",
      "3112/3112 [==============================] - 0s 147us/step - loss: 1.5737 - acc: 0.8583 - val_loss: 2.8168 - val_acc: 0.7726\n",
      "Epoch 29/50\n",
      "3112/3112 [==============================] - 0s 135us/step - loss: 1.6332 - acc: 0.8499 - val_loss: 2.6335 - val_acc: 0.7871\n",
      "Epoch 30/50\n",
      "3112/3112 [==============================] - 0s 144us/step - loss: 1.6197 - acc: 0.8541 - val_loss: 2.7046 - val_acc: 0.7813\n",
      "Epoch 31/50\n",
      "3112/3112 [==============================] - 0s 137us/step - loss: 1.5724 - acc: 0.8583 - val_loss: 2.6458 - val_acc: 0.7847\n",
      "Epoch 32/50\n",
      "3112/3112 [==============================] - 0s 147us/step - loss: 1.5384 - acc: 0.8573 - val_loss: 2.7548 - val_acc: 0.7784\n",
      "Epoch 33/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 1.5416 - acc: 0.8560 - val_loss: 2.6942 - val_acc: 0.7808\n",
      "Epoch 34/50\n",
      "3112/3112 [==============================] - 0s 145us/step - loss: 1.5780 - acc: 0.8538 - val_loss: 2.7261 - val_acc: 0.7755\n",
      "Epoch 35/50\n",
      "3112/3112 [==============================] - 0s 134us/step - loss: 1.5478 - acc: 0.8528 - val_loss: 2.6358 - val_acc: 0.7832\n",
      "Epoch 36/50\n",
      "3112/3112 [==============================] - 0s 135us/step - loss: 1.6300 - acc: 0.8477 - val_loss: 2.6163 - val_acc: 0.7871\n",
      "Epoch 37/50\n",
      "3112/3112 [==============================] - 0s 152us/step - loss: 1.5446 - acc: 0.8541 - val_loss: 2.6238 - val_acc: 0.7871\n",
      "Epoch 38/50\n",
      "3112/3112 [==============================] - 0s 137us/step - loss: 1.4815 - acc: 0.8631 - val_loss: 2.6222 - val_acc: 0.7876\n",
      "Epoch 39/50\n",
      "3112/3112 [==============================] - 0s 143us/step - loss: 1.5307 - acc: 0.8596 - val_loss: 2.6622 - val_acc: 0.7842\n",
      "Epoch 40/50\n",
      "3112/3112 [==============================] - 0s 134us/step - loss: 1.4757 - acc: 0.8615 - val_loss: 2.6584 - val_acc: 0.7775\n",
      "Epoch 41/50\n",
      "3112/3112 [==============================] - 0s 142us/step - loss: 1.4912 - acc: 0.8625 - val_loss: 2.7109 - val_acc: 0.7803\n",
      "Epoch 42/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 1.3912 - acc: 0.8676 - val_loss: 2.6428 - val_acc: 0.7823\n",
      "Epoch 43/50\n",
      "3112/3112 [==============================] - 0s 142us/step - loss: 1.4650 - acc: 0.8650 - val_loss: 2.7254 - val_acc: 0.7823\n",
      "Epoch 44/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 1.4426 - acc: 0.8602 - val_loss: 2.6579 - val_acc: 0.7861\n",
      "Epoch 45/50\n",
      "3112/3112 [==============================] - 0s 136us/step - loss: 1.3862 - acc: 0.8689 - val_loss: 2.7029 - val_acc: 0.7823\n",
      "Epoch 46/50\n",
      "3112/3112 [==============================] - 0s 147us/step - loss: 1.3805 - acc: 0.8638 - val_loss: 2.7139 - val_acc: 0.7770\n",
      "Epoch 47/50\n",
      "3112/3112 [==============================] - 0s 135us/step - loss: 1.4554 - acc: 0.8573 - val_loss: 2.6637 - val_acc: 0.7866\n",
      "Epoch 48/50\n",
      "3112/3112 [==============================] - 0s 152us/step - loss: 1.3979 - acc: 0.8625 - val_loss: 2.8353 - val_acc: 0.7635\n",
      "Epoch 49/50\n",
      "3112/3112 [==============================] - 0s 138us/step - loss: 1.4165 - acc: 0.8605 - val_loss: 2.6396 - val_acc: 0.7852\n",
      "Epoch 50/50\n",
      "3112/3112 [==============================] - 0s 146us/step - loss: 1.3335 - acc: 0.8689 - val_loss: 2.6142 - val_acc: 0.7837\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x7f89a361dc50>"
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wandb.init()\n",
    "model.fit(X_train, y_train_hot, epochs=config.epochs, validation_data=(X_test, y_test_hot), callbacks=[WandbCallback(data_type=\"image\", labels=labels)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 53,
   "metadata": {},
   "outputs": [
    {
     "ename": "ValueError",
     "evalue": "Input 0 is incompatible with layer lstm_2: expected ndim=3, found ndim=4",
     "output_type": "error",
     "traceback": [
      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[0;31mValueError\u001b[0m                                Traceback (most recent call last)",
      "\u001b[0;32m<ipython-input-53-6ac7b4c7af2c>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;31m# build model\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      2\u001b[0m \u001b[0mmodel\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mSequential\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 3\u001b[0;31m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mLSTM\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m16\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0minput_shape\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mconfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuckets\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mconfig\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax_len\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mchannels\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mactivation\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"sigmoid\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      4\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDense\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mactivation\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'sigmoid'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m \u001b[0mmodel\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0madd\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mDense\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnum_classes\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mactivation\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m'softmax'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/engine/sequential.py\u001b[0m in \u001b[0;36madd\u001b[0;34m(self, layer)\u001b[0m\n\u001b[1;32m    163\u001b[0m                     \u001b[0;31m# and create the node connecting the current layer\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    164\u001b[0m                     \u001b[0;31m# to the input layer we just created.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 165\u001b[0;31m                     \u001b[0mlayer\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    166\u001b[0m                     \u001b[0mset_inputs\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    167\u001b[0m             \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/layers/recurrent.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, inputs, initial_state, constants, **kwargs)\u001b[0m\n\u001b[1;32m    530\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    531\u001b[0m         \u001b[0;32mif\u001b[0m \u001b[0minitial_state\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mconstants\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 532\u001b[0;31m             \u001b[0;32mreturn\u001b[0m \u001b[0msuper\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mRNN\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0m__call__\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mkwargs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    533\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    534\u001b[0m         \u001b[0;31m# If any of `initial_state` or `constants` are specified and are Keras\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py\u001b[0m in \u001b[0;36m__call__\u001b[0;34m(self, inputs, **kwargs)\u001b[0m\n\u001b[1;32m    412\u001b[0m                 \u001b[0;31m# Raise exceptions in case the input is not compatible\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    413\u001b[0m                 \u001b[0;31m# with the input_spec specified in the layer constructor.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 414\u001b[0;31m                 \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0massert_input_compatibility\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0minputs\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m    415\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    416\u001b[0m                 \u001b[0;31m# Collect input shapes to build layer.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;32m/usr/local/lib/python3.6/dist-packages/keras/engine/base_layer.py\u001b[0m in \u001b[0;36massert_input_compatibility\u001b[0;34m(self, inputs)\u001b[0m\n\u001b[1;32m    309\u001b[0m                                      \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mname\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m': expected ndim='\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    310\u001b[0m                                      \u001b[0mstr\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mspec\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0;34m', found ndim='\u001b[0m \u001b[0;34m+\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 311\u001b[0;31m                                      str(K.ndim(x)))\n\u001b[0m\u001b[1;32m    312\u001b[0m             \u001b[0;32mif\u001b[0m \u001b[0mspec\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmax_ndim\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m    313\u001b[0m                 \u001b[0mndim\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mK\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mndim\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mx\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
      "\u001b[0;31mValueError\u001b[0m: Input 0 is incompatible with layer lstm_2: expected ndim=3, found ndim=4"
     ]
    }
   ],
   "source": [
    "\n",
    "# build model\n",
    "model = Sequential()\n",
    "model.add(LSTM(16, input_shape=(config.buckets, config.max_len, channels), activation=\"sigmoid\"))\n",
    "model.add(Dense(1, activation='sigmoid'))\n",
    "model.add(Dense(num_classes, activation='softmax'))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 48,
   "metadata": {},
   "outputs": [],
   "source": [
    "model.compile(loss=\"categorical_crossentropy\",\n",
    "                  optimizer=\"adam\",\n",
    "                  metrics=['accuracy'])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 49,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "W&B Run: https://app.wandb.ai/l2k2/ml-class-videos_cnn-audio/runs/dtwf65g1\n",
      "Call `%%wandb` in the cell containing your training loop to display live results.\n",
      "Train on 3112 samples, validate on 2076 samples\n",
      "Epoch 1/50\n",
      "3112/3112 [==============================] - 1s 407us/step - loss: 1.9623 - acc: 0.4762 - val_loss: 0.7156 - val_acc: 0.6946\n",
      "Epoch 2/50\n",
      "3112/3112 [==============================] - 1s 241us/step - loss: 0.7342 - acc: 0.6655 - val_loss: 0.5495 - val_acc: 0.7905\n",
      "Epoch 3/50\n",
      "3112/3112 [==============================] - 1s 236us/step - loss: 0.6346 - acc: 0.7265 - val_loss: 0.4503 - val_acc: 0.8295\n",
      "Epoch 4/50\n",
      "3112/3112 [==============================] - 1s 238us/step - loss: 0.5327 - acc: 0.7847 - val_loss: 0.3875 - val_acc: 0.8521\n",
      "Epoch 5/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.4546 - acc: 0.8194 - val_loss: 0.3664 - val_acc: 0.8545\n",
      "Epoch 6/50\n",
      "3112/3112 [==============================] - 1s 229us/step - loss: 0.4234 - acc: 0.8316 - val_loss: 0.3349 - val_acc: 0.8801\n",
      "Epoch 7/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.3969 - acc: 0.8451 - val_loss: 0.3191 - val_acc: 0.8844\n",
      "Epoch 8/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.3583 - acc: 0.8670 - val_loss: 0.2884 - val_acc: 0.8863\n",
      "Epoch 9/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.3428 - acc: 0.8663 - val_loss: 0.2585 - val_acc: 0.9017\n",
      "Epoch 10/50\n",
      "3112/3112 [==============================] - 1s 227us/step - loss: 0.3109 - acc: 0.8753 - val_loss: 0.2971 - val_acc: 0.8868\n",
      "Epoch 11/50\n",
      "3112/3112 [==============================] - 1s 228us/step - loss: 0.3099 - acc: 0.8869 - val_loss: 0.2573 - val_acc: 0.9032\n",
      "Epoch 12/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.2891 - acc: 0.8856 - val_loss: 0.2547 - val_acc: 0.9037\n",
      "Epoch 13/50\n",
      "3112/3112 [==============================] - 1s 223us/step - loss: 0.2641 - acc: 0.8997 - val_loss: 0.2315 - val_acc: 0.9128\n",
      "Epoch 14/50\n",
      "3112/3112 [==============================] - 1s 231us/step - loss: 0.2698 - acc: 0.8962 - val_loss: 0.2482 - val_acc: 0.9056\n",
      "Epoch 15/50\n",
      "3112/3112 [==============================] - 1s 229us/step - loss: 0.2616 - acc: 0.9026 - val_loss: 0.2451 - val_acc: 0.9051\n",
      "Epoch 16/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.2394 - acc: 0.9100 - val_loss: 0.2324 - val_acc: 0.9099\n",
      "Epoch 17/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.2264 - acc: 0.9075 - val_loss: 0.2356 - val_acc: 0.9090\n",
      "Epoch 18/50\n",
      "3112/3112 [==============================] - 1s 239us/step - loss: 0.2157 - acc: 0.9216 - val_loss: 0.2173 - val_acc: 0.9157\n",
      "Epoch 19/50\n",
      "3112/3112 [==============================] - 1s 224us/step - loss: 0.2293 - acc: 0.9139 - val_loss: 0.2387 - val_acc: 0.9022\n",
      "Epoch 20/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.2352 - acc: 0.9148 - val_loss: 0.2359 - val_acc: 0.9128\n",
      "Epoch 21/50\n",
      "3112/3112 [==============================] - 1s 229us/step - loss: 0.2068 - acc: 0.9229 - val_loss: 0.2154 - val_acc: 0.9249\n",
      "Epoch 22/50\n",
      "3112/3112 [==============================] - 1s 228us/step - loss: 0.1956 - acc: 0.9267 - val_loss: 0.2237 - val_acc: 0.9258\n",
      "Epoch 23/50\n",
      "3112/3112 [==============================] - 1s 228us/step - loss: 0.1971 - acc: 0.9242 - val_loss: 0.3137 - val_acc: 0.8935\n",
      "Epoch 24/50\n",
      "3112/3112 [==============================] - 1s 223us/step - loss: 0.2352 - acc: 0.9136 - val_loss: 0.2334 - val_acc: 0.9176\n",
      "Epoch 25/50\n",
      "3112/3112 [==============================] - 1s 233us/step - loss: 0.1856 - acc: 0.9316 - val_loss: 0.2142 - val_acc: 0.9152\n",
      "Epoch 26/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.1832 - acc: 0.9312 - val_loss: 0.2065 - val_acc: 0.9292\n",
      "Epoch 27/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.1804 - acc: 0.9328 - val_loss: 0.2450 - val_acc: 0.9157\n",
      "Epoch 28/50\n",
      "3112/3112 [==============================] - 1s 224us/step - loss: 0.1728 - acc: 0.9354 - val_loss: 0.2183 - val_acc: 0.9196\n",
      "Epoch 29/50\n",
      "3112/3112 [==============================] - 1s 236us/step - loss: 0.1798 - acc: 0.9393 - val_loss: 0.2097 - val_acc: 0.9234\n",
      "Epoch 30/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1751 - acc: 0.9338 - val_loss: 0.2001 - val_acc: 0.9292\n",
      "Epoch 31/50\n",
      "3112/3112 [==============================] - 1s 229us/step - loss: 0.1656 - acc: 0.9418 - val_loss: 0.2071 - val_acc: 0.9200\n",
      "Epoch 32/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1761 - acc: 0.9354 - val_loss: 0.2080 - val_acc: 0.9282\n",
      "Epoch 33/50\n",
      "3112/3112 [==============================] - 1s 231us/step - loss: 0.1466 - acc: 0.9499 - val_loss: 0.2136 - val_acc: 0.9277\n",
      "Epoch 34/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1671 - acc: 0.9409 - val_loss: 0.2059 - val_acc: 0.9277\n",
      "Epoch 35/50\n",
      "3112/3112 [==============================] - 1s 221us/step - loss: 0.1617 - acc: 0.9418 - val_loss: 0.2105 - val_acc: 0.9273\n",
      "Epoch 36/50\n",
      "3112/3112 [==============================] - 1s 230us/step - loss: 0.1632 - acc: 0.9415 - val_loss: 0.2111 - val_acc: 0.9297\n",
      "Epoch 37/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1933 - acc: 0.9351 - val_loss: 0.2138 - val_acc: 0.9215\n",
      "Epoch 38/50\n",
      "3112/3112 [==============================] - 1s 222us/step - loss: 0.1430 - acc: 0.9467 - val_loss: 0.1988 - val_acc: 0.9321\n",
      "Epoch 39/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1409 - acc: 0.9470 - val_loss: 0.2236 - val_acc: 0.9263\n",
      "Epoch 40/50\n",
      "3112/3112 [==============================] - 1s 231us/step - loss: 0.1309 - acc: 0.9553 - val_loss: 0.2243 - val_acc: 0.9292\n",
      "Epoch 41/50\n",
      "3112/3112 [==============================] - 1s 226us/step - loss: 0.1385 - acc: 0.9492 - val_loss: 0.2892 - val_acc: 0.9090\n",
      "Epoch 42/50\n",
      "3112/3112 [==============================] - 1s 225us/step - loss: 0.1637 - acc: 0.9389 - val_loss: 0.2295 - val_acc: 0.9306\n",
      "Epoch 43/50\n",
      "3112/3112 [==============================] - 1s 231us/step - loss: 0.1329 - acc: 0.9492 - val_loss: 0.2125 - val_acc: 0.9229\n",
      "Epoch 44/50\n",
      "3112/3112 [==============================] - 1s 233us/step - loss: 0.1269 - acc: 0.9528 - val_loss: 0.2149 - val_acc: 0.9258\n",
      "Epoch 45/50\n",
      "3112/3112 [==============================] - 1s 227us/step - loss: 0.1230 - acc: 0.9569 - val_loss: 0.2008 - val_acc: 0.9297\n",
      "Epoch 46/50\n",
      "3112/3112 [==============================] - 1s 222us/step - loss: 0.1400 - acc: 0.9454 - val_loss: 0.2512 - val_acc: 0.9210\n",
      "Epoch 47/50\n",
      "3112/3112 [==============================] - 1s 227us/step - loss: 0.1363 - acc: 0.9486 - val_loss: 0.2346 - val_acc: 0.9215\n",
      "Epoch 48/50\n",
      "3112/3112 [==============================] - 1s 227us/step - loss: 0.1239 - acc: 0.9550 - val_loss: 0.2463 - val_acc: 0.9147\n",
      "Epoch 49/50\n",
      "3112/3112 [==============================] - 1s 236us/step - loss: 0.1379 - acc: 0.9499 - val_loss: 0.2148 - val_acc: 0.9306\n",
      "Epoch 50/50\n",
      "3112/3112 [==============================] - 1s 221us/step - loss: 0.1204 - acc: 0.9528 - val_loss: 0.2149 - val_acc: 0.9311\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "<keras.callbacks.History at 0x7f89a8f7da20>"
      ]
     },
     "execution_count": 49,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "wandb.init()\n",
    "model.fit(X_train, y_train_hot, epochs=config.epochs, validation_data=(X_test, y_test_hot), callbacks=[WandbCallback(data_type=\"image\", labels=labels)])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
